//************************************************************
//---------------XiAn AnaDig IC Inc.(XAD-IC)------------------
//-----------------C and ASM File Standard--------------------

/************************INCLUDES****************************/
#include "XAD1606.h"
#include "periph.h"
#include "commdef.h"
#include "usart.h"
#include <stdio.h>


#define WORK_TIMER 300
#define LED_BLUE_H (IO_LED_BLUE = 1)
#define LED_BLUE_L (IO_LED_BLUE = 0)

#define LED_RED_H (IO_LED_RED = 1)
#define LED_RED_L (IO_LED_RED = 0)


/************************************************************/

__CONFIG(OTP_MODE_4K & RDPIN_ON     & FINTOSC_DIV1      & LVT_20V                                            );
__CONFIG(OTPDIS_ON   & PROTECT_OFF  & IO_MODE1          & OSCM_16M   & RESSEL_LOW   &  FCPUS_4T   &  IDIS_OFF);
__CONFIG(RESETE_OFF  & LVTEN_OFF     & MCU_SEL_ADCPU2    & WDTE_OFF   & TWDT_011                              );  


vu8 TestFlag=0;

void main(void)
{
	SystemClock();
	GpioConfig();
	ExternalInterruptConfig();
	//Timer0InterruptConfig();
	
   while(1)   
   { 
	   //AlgorithmThree();
   }	  
}

void interrupt ISR (void)
{
	if((T0IF==1)&&(T0IE=1))//Timer0 1ms
	{
		T0IF=0;
		CollectionLow++;
		CollectionHig++;
	}
	if((INT0IE == 1)&&(INT0IF == 1))	 //INT0 上触发
	{	
		static uint8_t i=0;
		INT0IF=0; 
		if(i==0)
		{
			TestFlag=0;
			i=1;
		}
		else
		{
			TestFlag=1; 
		}
	} 
	if((INT1IE == 1)&&(INT1IF == 1))	 //INT1 下触发
	{
		static uint8_t j=0;
		INT1IF=0; 
		if(j==0)
		{
			TestFlag=0;
			j=1;
		}
		else
		{
			TestFlag=0;
		}
	} 
}



